package com.example.demo.Entity;


import org.hibernate.validator.constraints.Length;
import sun.awt.image.IntegerInterleavedRaster;

import javax.validation.constraints.*;
import java.util.Date;

public class Employee {
    private int id;

//    @Length(min = 6, max = 15, message = "lastName必须在6至15之间")
    @Size(min = 6, max = 15, message = "lastName必须在6至15之间")
    @NotEmpty(message = "lastName不能为空")
    private String lastName;

//    @Email 在为空的时候，会通过验证！这个需要小心！
//    NULL字符串一定是一个empty字符串，而一个empty字符串未必是一个NULL字符串!!
    @NotEmpty(message = "email不能为empty")
    @NotNull(message = "email不能为null")
    @Email
    private String email;


    private int gender;

    private int d_id;


    @Past(message = "时间需要是过去的！")
    private Date birthday;

    public Employee() {
    }

    public Employee(int id, @Size(min = 6, max = 15, message = "lastName必须在6至15之间") @NotEmpty(message = "lastName不能为空") String lastName, @NotEmpty(message = "email不能为empty") @NotNull(message = "email不能为null") @Email String email, int gender, int d_id, Date birthday) {
        this.id = id;
        this.lastName = lastName;
        this.email = email;
        this.gender = gender;
        this.d_id = d_id;
        this.birthday = birthday;
    }

    @Override
    public String toString() {
        return "Employee{" +
                "id=" + id +
                ", lastName='" + lastName + '\'' +
                ", email='" + email + '\'' +
                ", gender=" + gender +
                ", d_id=" + d_id +
                ", birthday=" + birthday +
                '}';
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public int getGender() {
        return gender;
    }

    public void setGender(int gender) {
        this.gender = gender;
    }

    public int getD_id() {
        return d_id;
    }

    public void setD_id(int d_id) {
        this.d_id = d_id;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }
}
